package com.sateh.spaces.examples.helloworld;

import com.sateh.spaces.*;
import com.sateh.spaces.simple.SimpleSpaceConnectionFactory;

public class HelloWorld
{
    public static void main(String[] args) throws SpaceException, UnusableEntryException
    {
        SpaceConnectionFactory spaceConnectionFactory = new SimpleSpaceConnectionFactory("vm://HelloWorld");
        SpaceConnection spaceConnection = spaceConnectionFactory.createConnection();

        Message message = new Message();
        message.setContent("Hello, world");

        spaceConnection.write(message, null, Lease.FOREVER);

        Message template = new Message();
        Message result = spaceConnection.read(Message.class, null, Long.MAX_VALUE);

        System.out.println("Found Message: " + result.getContent());
    }
}
